﻿namespace WMS6.Web
{
    using System.Data;
    using System.Web;
    using WMS6.Web.CustomizeReportServiceRef;

    public class CustomizeReportServiceClientProxy : BasePage
    {
        public static CustomizeReportServiceClientProxy GetInstance()
        {
            return new CustomizeReportServiceClientProxy();
        }

        public DataSet GetNSNPerformanceReportByDataSet(NSNPerformanceReportQueryEntity nsnPerformanceReportQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CustomizeReportServiceClient client = new CustomizeReportServiceClient("WSHttpBinding_ICustomizeReportService"))
            {
                return client.GetNSNPerformanceReportByDataSet(nsnPerformanceReportQueryEntity, pubParasInfo);
            }
        }

        public DataSet GetTNTDailyInventoryRptDataSet(InventoryQueryEntity inventoryQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CustomizeReportServiceClient client = new CustomizeReportServiceClient("WSHttpBinding_ICustomizeReportService"))
            {
                return client.GetTNTDailyInventoryRptDataSet(inventoryQueryEntity, pubParasInfo);
            }
        }

        public DataSet GetTNTInOutStockInvRptDataSet(TNTInOutStockInvRptQueryEntity tntInOutStockInvRptQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CustomizeReportServiceClient client = new CustomizeReportServiceClient("WSHttpBinding_ICustomizeReportService"))
            {
                return client.GetTNTInOutStockInvRptDataSet(tntInOutStockInvRptQueryEntity, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }
    }
}

